com.rscja.team.qcom.usb.pl2302

## Class UsbSerialPortImpl_qcom

- java.lang.Object
- - com.rscja.team.qcom.usb.pl2302.UsbSerialPortImpl_qcom

- All Implemented Interfaces:
    UsbSerialPort_qcom

      public class UsbSerialPortImpl_qcom
      extends java.lang.Object
      implements UsbSerialPort_qcom

- - ### Field Summary

    - ### Fields inherited from interface com.rscja.team.qcom.usb.pl2302.UsbSerialPort_qcom

      `DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UsbSerialPortImpl_qcom(android.hardware.usb.UsbDeviceConnection mConnection)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the port.
    `boolean` | `getCD()` Gets the CD (Carrier Detect) bit from the underlying UART.
    `boolean` | `getCTS()` Gets the CTS (Clear To Send) bit from the underlying UART.
    `boolean` | `getDSR()` Gets the DSR (Data Set Ready) bit from the underlying UART.
    `boolean` | `getDTR()` Gets the DTR (Data Terminal Ready) bit from the underlying UART.
    `int` | `getPortNumber()` Port number within driver.
    `boolean` | `getRI()` Gets the RI (Ring Indicator) bit from the underlying UART.
    `boolean` | `getRTS()` Gets the RTS (Request To Send) bit from the underlying UART.
    `java.lang.String` | `getSerial()` The serial number of the underlying UsbDeviceConnection, or `null`.
    `void` | `open(android.hardware.usb.UsbDeviceConnection connection)` Opens and initializes the port.
    `boolean` | `purgeHwBuffers(boolean flushRX, boolean flushTX)` Flush non-transmitted output data and / or non-read input data
    `int` | `read(byte[] dest, int timeoutMillis)` Reads as many bytes as possible into the destination buffer.
    `void` | `setDTR(boolean value)` Sets the DTR (Data Terminal Ready) bit on the underlying UART, if supported.
    `boolean` | `setParameters()`
    `void` | `setParameters(int baudRate, int dataBits, int stopBits, int parity)` Sets various serial port parameters.
    `void` | `setRTS(boolean value)` Sets the RTS (Request To Send) bit on the underlying UART, if supported.
    `int` | `write(byte[] src, int timeoutMillis)` Writes as many bytes as possible from the source buffer.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UsbSerialPortImpl_qcom

          public UsbSerialPortImpl_qcom(android.hardware.usb.UsbDeviceConnection mConnection)

  - ### Method Detail

    - #### getPortNumber

          public int getPortNumber()

      Description copied from interface: `UsbSerialPort_qcom`
      Port number within driver.
      Specified by:
        `getPortNumber` in interface `UsbSerialPort_qcom`

    - #### getSerial

          public java.lang.String getSerial()

      Description copied from interface: `UsbSerialPort_qcom`
      The serial number of the underlying UsbDeviceConnection, or `null`.
      Specified by:
        `getSerial` in interface `UsbSerialPort_qcom`

    - #### open

          public void open(android.hardware.usb.UsbDeviceConnection connection)
                    throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Opens and initializes the port. Upon success, caller must ensure that is eventually called.
      Specified by:
        `open` in interface `UsbSerialPort_qcom`
      Parameters:
        `connection` - an open device connection, acquired with `UsbManager.openDevice(android.hardware.usb.UsbDevice)`
      Throws:
        `java.io.IOException` - on error opening or initializing the port.

    - #### close

          public void close()
                     throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Closes the port.
      Specified by:
        `close` in interface `UsbSerialPort_qcom`
      Throws:
        `java.io.IOException` - on error closing the port.

    - #### read

          public int read(byte[] dest,
                          int timeoutMillis)
                   throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Reads as many bytes as possible into the destination buffer.
      Specified by:
        `read` in interface `UsbSerialPort_qcom`
      Parameters:
        `dest` - the destination byte buffer
        `timeoutMillis` - the timeout for reading
      Returns:
        the actual number of bytes read
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### write

          public int write(byte[] src,
                           int timeoutMillis)
                    throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Writes as many bytes as possible from the source buffer.
      Specified by:
        `write` in interface `UsbSerialPort_qcom`
      Parameters:
        `src` - the source byte buffer
        `timeoutMillis` - the timeout for writing
      Returns:
        the actual number of bytes written
      Throws:
        `java.io.IOException` - if an error occurred during writing

    - #### setParameters

          public boolean setParameters()

      Specified by:
        `setParameters` in interface `UsbSerialPort_qcom`

    - #### setParameters

          public void setParameters(int baudRate,
                                    int dataBits,
                                    int stopBits,
                                    int parity)
                             throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Sets various serial port parameters.
      Specified by:
        `setParameters` in interface `UsbSerialPort_qcom`
      Parameters:
        `baudRate` - baud rate as an integer, for example `115200`.
        `dataBits` - one of `UsbSerialPort_qcom.DATABITS_5`, `UsbSerialPort_qcom.DATABITS_6`, `UsbSerialPort_qcom.DATABITS_7`, or `UsbSerialPort_qcom.DATABITS_8`.
        `stopBits` - one of `UsbSerialPort_qcom.STOPBITS_1`, `UsbSerialPort_qcom.STOPBITS_1_5`, or `UsbSerialPort_qcom.STOPBITS_2`.
        `parity` - one of `UsbSerialPort_qcom.PARITY_NONE`, `UsbSerialPort_qcom.PARITY_ODD`, `UsbSerialPort_qcom.PARITY_EVEN`, `UsbSerialPort_qcom.PARITY_MARK`, or `UsbSerialPort_qcom.PARITY_SPACE`.
      Throws:
        `java.io.IOException` - on error setting the port parameters

    - #### getCD

          public boolean getCD()
                        throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the CD (Carrier Detect) bit from the underlying UART.
      Specified by:
        `getCD` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### getCTS

          public boolean getCTS()
                         throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the CTS (Clear To Send) bit from the underlying UART.
      Specified by:
        `getCTS` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### getDSR

          public boolean getDSR()
                         throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the DSR (Data Set Ready) bit from the underlying UART.
      Specified by:
        `getDSR` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### getDTR

          public boolean getDTR()
                         throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the DTR (Data Terminal Ready) bit from the underlying UART.
      Specified by:
        `getDTR` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### setDTR

          public void setDTR(boolean value)
                      throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Sets the DTR (Data Terminal Ready) bit on the underlying UART, if supported.
      Specified by:
        `setDTR` in interface `UsbSerialPort_qcom`
      Parameters:
        `value` - the value to set
      Throws:
        `java.io.IOException` - if an error occurred during writing

    - #### getRI

          public boolean getRI()
                        throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the RI (Ring Indicator) bit from the underlying UART.
      Specified by:
        `getRI` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### getRTS

          public boolean getRTS()
                         throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Gets the RTS (Request To Send) bit from the underlying UART.
      Specified by:
        `getRTS` in interface `UsbSerialPort_qcom`
      Returns:
        the current state, or `false` if not supported.
      Throws:
        `java.io.IOException` - if an error occurred during reading

    - #### setRTS

          public void setRTS(boolean value)
                      throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Sets the RTS (Request To Send) bit on the underlying UART, if supported.
      Specified by:
        `setRTS` in interface `UsbSerialPort_qcom`
      Parameters:
        `value` - the value to set
      Throws:
        `java.io.IOException` - if an error occurred during writing

    - #### purgeHwBuffers

          public boolean purgeHwBuffers(boolean flushRX,
                                        boolean flushTX)
                                 throws java.io.IOException

      Description copied from interface: `UsbSerialPort_qcom`
      Flush non-transmitted output data and / or non-read input data
      Specified by:
        `purgeHwBuffers` in interface `UsbSerialPort_qcom`
      Parameters:
        `flushRX` - `true` to flush non-transmitted output data
        `flushTX` - `true` to flush non-read input data
      Returns:
        `true` if the operation was successful, or `false` if the operation is not supported by the driver or device
      Throws:
        `java.io.IOException` - if an error occurred during flush